home *** CD-ROM | disk | FTP | other *** search
/ Packard Bell Multi-Media Master / Packard Bell Multi-Media Master.iso / diskimag / pnp.121 / disk1.img / SETUP.MS_ / SETUP.bin
Encoding:
Text File  |  1994-06-22  |  14.8 KB  |  526 lines

  1. '******************************************************************************
  2. '**  Auto-configuration software setup script
  3. '******************************************************************************
  4.  
  5. ''$DEFINE DUMPLIST
  6. ''$DEFINE NOCOPY
  7.  
  8. '$INCLUDE 'setupapi.inc'
  9. '$INCLUDE 'msdetect.inc'
  10.  
  11. '' WINDOWS SYSTEM ID's
  12. CONST IDYES                = 6
  13. CONST IDNO                = 7
  14.  
  15. '' Message Box ID's
  16.  
  17. CONST MB_YESNO             = 4
  18. CONST MB_ICONQUSTION     = 32
  19.  
  20. '' Dialog ID's
  21. CONST WELCOME       = 100
  22. CONST DONTUSE       = 150
  23. CONST ASKQUIT       = 200
  24. CONST DESTPATH      = 300
  25. CONST EXITFAILURE   = 400
  26. CONST EXITQUIT      = 600
  27. CONST EXITSUCCESS   = 700
  28. CONST OPTIONS       = 800
  29. CONST APPHELP       = 900
  30. CONST TOOBIG        = 6300
  31. CONST BADPATH       = 6400
  32.  
  33. CONST LOGO = 1      '' bitmap ID - identifies bitmap in DIALOGS.RC
  34.  
  35. '' GLOBAL VARAIBLES
  36. GLOBAL DEST$        '' destination directory
  37. GLOBAL YESNO%
  38. GLOBAL szESCD%
  39.  
  40. '' function declarations
  41. DECLARE SUB Install
  42. DECLARE SUB AddDosDriver( szFile$, szDevText$ )
  43. DECLARE SUB CommentOutVxD( szVxD$, szWindowsDir$ )
  44. DECLARE FUNCTION MakePath( szDir$, szFile$ ) AS STRING
  45. DECLARE SUB AddBuffers
  46.  
  47.  
  48. ''String Defs.
  49. YESNOMSG$ = "An ESCD.RF file has been detected.  Do you want to overwrite it ?"
  50.  
  51.  
  52. INIT:
  53.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  54.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  55.  
  56.     '' put opening bitmap on the screen
  57.     SetBitmap CUIDLL$, LOGO
  58.     SetTitle "Plug and Play Kit for Windows"
  59.  
  60.     '' figure out where the .INF file is and read it
  61.     szInf$ = GetSymbolValue( "STF_SRCINFPATH" )
  62.     IF szInf$ = "" THEN
  63.         szInf$ = GetSymbolValue( "STF_CWDDIR" ) + "SETUP.INF"
  64.     END IF
  65.     ReadInfFile szInf$
  66.  
  67.     '' identify the default Plug and Play installation directory
  68.     DEST$ = "C:\PLUGPLAY"
  69.  
  70.  
  71. WELCOME:
  72.     SetAbout "Plug and Play Kit for Windows", "Copyright 1993, 1994 Intel Corporation, All Rights Reserved"
  73.     sz$ = UIStartDlg( CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$ )
  74.     IF sz$ = "CONTINUE" THEN
  75.         UIPop 1
  76.     ELSE
  77.         GOSUB ASKQUIT
  78.         GOTO WELCOME
  79.     END IF
  80.  
  81. DONTUSE:
  82.     sz$ = UIStartDlg( CUIDLL$, DONTUSE, "FInfoDlgProc", APPHELP, HELPPROC$ )
  83.     IF sz$ = "CONTINUE" THEN
  84.         UIPop 1
  85.     ELSE
  86.         GOSUB ASKQUIT
  87.         GOTO WELCOME
  88.     END IF
  89.  
  90. GETPATH:
  91.     SetSymbolValue "EditTextIn", DEST$
  92.     SetSymbolValue "EditFocus", "END"
  93. GETPATHL1:
  94.     '' present window for user to select Plug and Play install directory
  95.     sz$ = UIStartDlg( CUIDLL$, DESTPATH, "FEditDlgProc", 0, "" )
  96.     DEST$ = GetSymbolValue( "EditTextOut" )
  97.  
  98.     IF sz$ = "CONTINUE" THEN
  99.         IF IsDirWritable( DEST$ ) = 0 THEN
  100.             GOSUB BADPATH
  101.             GOTO GETPATHL1
  102.         END IF
  103.         UIPop 1
  104.     ELSEIF sz$ = "REACTIVATE" THEN
  105.         GOTO GETPATHL1
  106.     ELSEIF sz$ = "BACK" THEN
  107.         UIPop 1
  108.         GOTO WELCOME
  109.     ELSE
  110.         GOSUB ASKQUIT
  111.         GOTO GETPATH
  112.     END IF
  113.  
  114.     '' Check to see if there is enough space on the target disk.        
  115. CKSIZE:
  116.     DRIVE$ = MID$(DEST$,1,1)
  117.     FREE& = GetFreeSpaceForDrive(drive$)
  118.     IF FREE < 2500000 THEN 
  119.     GOTO TOOBIG
  120.  
  121. EndIf
  122.  
  123. ISESCD:
  124.     szESCD% = DoesFileExist("C:\ESCD.RF", fenExists)
  125.     If szESCD% = 1 Then
  126.         yesno% = DoMsgBox( YESNOMSG$, "ESCD.RF FOUND", MB_YESNO+MB_ICONQUESTION)
  127.     EndIF
  128.  
  129.     If ( szESCD% =1 and yesno% = IDYES) THEN
  130.             BackupFile "C:\ESCD.RF", "ESCD.BAK" 
  131.     EndIf
  132.         
  133.     '' We have an installation directory and know where the Windows directory
  134.     '' and the Windows SYSTEM directory are.  Now call the Install subroutine
  135.     '' to do the real work
  136.  
  137.     Install
  138.  
  139.  
  140. QUIT:
  141.     ON ERROR GOTO ERRQUIT
  142.  
  143.     IF ERR = 0 THEN
  144.         dlg% = EXITSUCCESS
  145.     ELSEIF ERR = STFQUIT THEN
  146.         dlg% = EXITQUIT
  147.     ELSE
  148.         dlg% = EXITFAILURE
  149.     END IF
  150. QUITL1:
  151.     sz$ = UIStartDlg( CUIDLL$, dlg%, "FInfo0DlgProc", 0, "" )
  152.     IF sz$ = "REACTIVATE" THEN
  153.         GOTO QUITL1
  154.     END IF
  155.     UIPop 1
  156.  
  157.     END
  158.  
  159.  
  160. ERRQUIT:
  161.     i% = DoMsgBox( "Software installation is incomplete", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND )
  162.     END
  163.  
  164.  
  165. BADPATH:
  166.     sz$ = UIStartDlg( CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "" )
  167.     IF sz$ = "REACTIVATE" THEN
  168.         GOTO BADPATH
  169.     END IF
  170.     UIPop 1
  171.     RETURN
  172.  
  173.  
  174. ASKQUIT:
  175.     sz$ = UIStartDlg( CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "" )
  176.  
  177.     IF sz$ = "EXIT" THEN
  178.         UIPopAll
  179.         ERROR STFQUIT
  180.     ELSEIF sz$ = "REACTIVATE" THEN
  181.         GOTO ASKQUIT
  182.     ELSE
  183.         UIPop 1
  184.     END IF
  185.     RETURN
  186.  
  187. TOOBIG:
  188.     sz$ = UIStartDlg( CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "" )
  189.     IF sz$ = "REACTIVATE" THEN
  190.         GOTO TOOBIG
  191.     ELSEIF sz$ = "CONTINUE" THEN
  192.         UIPop 1
  193.         dlg% = EXITFAILURE
  194.         GOTO QUITL1
  195.     END IF
  196.     RETURN
  197.  
  198. '******************************************************************************
  199. '** subroutine:  Install
  200. '**
  201. '** Purpose:
  202. '**     Builds the copy list and performs all installation operations.
  203. '** Arguments:
  204. '**     none.
  205. '** Returns:
  206. '**     none.
  207. '******************************************************************************
  208. SUB Install STATIC
  209.  
  210.     SrcDir$ = GetSymbolValue( "STF_SRCDIR" )
  211.  
  212.     '' create Plug and Play installation directory
  213.     ''
  214.     CreateDir DEST$, cmoVital
  215.  
  216.     '' create subdirectories for ICU, ICU\DB, and DRIVERS\DOS
  217.     ''
  218.     ICUdir$ = MakePath( DEST$, "ICU" )
  219.     CreateDir ICUdir$, cmoVital
  220.  
  221.     DBdir$ = MakePath( ICUdir$, "DB" )
  222.     CreateDir DBdir$, cmoVital
  223.  
  224.     CMdir$ = MakePath( DEST$, "DRIVERS" )
  225.     CreateDir CMdir$, cmoVital
  226.  
  227.     DCMdir$ = MakePath( CMdir$, "DOS" )
  228.     CreateDir DCMdir$, cmoVital
  229.  
  230.     '' locate Windows installation directory and SYSTEM subdirectory
  231.     ''
  232.     WinDir$ = GetWindowsDir()
  233.     WinSys$ = GetWindowsSysDir()
  234.     SysIni$ = WinDir$ + "SYSTEM.INI"
  235.     SysBak$ = MakePath( DEST$, "SYSTEM.BAK" )
  236.  
  237.     '' Remove old readme files from previous installations
  238.     RemoveFile ICUdir$ + "\README.WIN", cmoForce
  239.     RemoveFile ICUdir$ + "\README.DOS", cmoForce
  240.     RemoveFile ICUdir$ + "\README.CM", cmoForce
  241.     RemoveFile DEST$ + "\README.CM", cmoForce
  242.     RemoveFile DEST$ + "\README.DDK", cmoForce
  243.  
  244.     '' create file copy list from sections in .INF file
  245.     ''
  246.     AddSectionFilesToCopyList "ICU_readme",      SrcDir$, DEST$
  247.     AddSectionFilesToCopyList "ICU_binaries",    SrcDir$, ICUdir$
  248.     AddSectionFilesToCopyList "ICU_database",    SrcDir$, ICUdir$
  249.     AddSectionFilesToCopyList "ESCD_image",      SrcDir$, DCMdir$
  250.     AddSectionFilesToCopyList "DOS_CM_binaries", SrcDir$, DCMdir$
  251.     AddSectionFilesToCopyList "Win_CM_binaries", SrcDir$, WinSys$
  252.     AddSectionFilesToCopyList "ICU_winsys",      SrcDir$, WinSys$
  253.     If ( (szESCD% =1 AND YESNO% = IDYES) OR (szESCD% = 0)) THEN
  254.         AddSectionFilesToCopyList "ESCD_image",      SrcDir$, "C:\"
  255.     EndIf
  256.     '$IFDEF DUMPLIST
  257.     DumpCopyList "C:\~WINICU.LST"
  258.     '$ENDIF
  259.  
  260.     '$IFNDEF NOCOPY
  261.     '' copy files to appropriate locations
  262.      CopyFilesInCopyList
  263.  
  264.     '' create WINICU.INI in the Windows directory with the installation values
  265.     ''   [Pathnames]
  266.     ''   ICUDir=C:\PLUGPLAY\ICU
  267.     ''   Database=DB
  268.     ''   Indexfile=ICU.NDX
  269.     ''   Imagefile=SYSTEM.IMG
  270.     ''
  271.     '' note that Setup does not create the [Settings] section or any keys in it;
  272.     '' WinICU creates/updates these at runtime
  273.     ''
  274.     ICUini$ = WinDir$ + "WINICU.INI"
  275.     RemoveIniKey ICUini$, "Settings", "HideUnchangeableCards", cmoNone
  276.     CreateIniKeyValue ICUini$, "Pathnames", "ICUDir",    ICUdir$,      cmoOverwrite
  277.     CreateIniKeyValue ICUini$, "Pathnames", "Database",  "DB",         cmoOverwrite
  278.     CreateIniKeyValue ICUini$, "Pathnames", "Indexfile", "ICU.NDX",    cmoOverwrite
  279.     CreateIniKeyValue ICUini$, "Pathnames", "Imagefile", "SYSTEM.IMG", cmoOverwrite
  280.     '$ENDIF '' NOCOPY
  281.  
  282.     '' add a DEVICE= line for the DOS CM driver in CONFIG.SYS
  283.     ''
  284.     szDevText$ = MakePath( DCMdir$, "DWCFGMG.SYS" )
  285.  
  286.     AddBuffers
  287.     AddDosDriver "DWCFGMG.SYS", szDevText$
  288.  
  289.     '$IFNDEF NOCOPY
  290.     '' check for a key in WIN.INI - if there is none, create one and add the CM
  291.     '' drivers to SYSTEM.INI
  292.     ''
  293.     sz$ = GetIniKeyString( "WIN.INI", "ConfigMgr", "Installed" )
  294.     IF sz$ = "yes" THEN
  295.         GOTO VXDINSTALLED
  296.     END IF
  297.     CreateIniKeyValue "WIN.INI", "ConfigMgr", "Installed", "yes", cmoNone
  298.  
  299.     '' backup SYSTEM.INI, then add device entries for CA and CM in [386Enh] section
  300.     ''
  301.     CopyFile SysIni$, SysBak$, cmoOverwrite, 0
  302.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "VCAD.386", cmoVital
  303.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "VCMD.386", cmoVital
  304.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "PCCARDRM.386", cmoVital
  305.  
  306.     CommentOutVxD "PCCARDRM.386", WinDir$
  307.  
  308. VXDINSTALLED:
  309.  
  310.     '' create Plug and Play program group in Program Manager - contains ICU
  311.     '' executable and README.TXT
  312.     ''
  313.     CreateProgmanGroup "Plug and Play", "", cmoNone
  314.     ShowProgmanGroup   "Plug and Play", 1,  cmoNone
  315.     CreateProgmanItem  "Plug and Play", "Intel ISA Configuration Utility", MakePath( ICUdir$,"WINICU.EXE" ), "", cmoOverwrite
  316.     CreateProgmanItem  "Plug and Play", "Release Notes", "NOTEPAD.EXE "+MakePath( DEST$,"README.TXT" ), "", cmoOverwrite
  317.     CreateProgmanItem  "Plug and Play", "ICU User's Guide", "WINHELP.EXE "+MakePath( ICUdir$,"ICUUG.HLP" ), "", cmoOverwrite
  318.     '$ENDIF '' NOCOPY
  319.  
  320.  
  321. MKNDX:
  322.     CHDRIVE DEST$
  323.     CHDIR DEST$ + "\ICU\DB"
  324.     SHELL DEST$ + "\ICU\DB\CFGNDX.EXE"
  325.     CHDRIVE szInf$
  326.  
  327. END SUB
  328.  
  329.  
  330. '******************************************************************************
  331. '**
  332. '** subroutine:  AddDosDriver
  333. '**
  334. '** Purpose:   Adds a DEVICE=<file> entry to CONFIG.SYS for the specified file.
  335. '**            An existing line in CONFIG.SYS with the same filename will be
  336. '**            deleted.  If CONFIG.SYS doesn't exist, a new one is created.
  337. '**            An existing CONFIG.SYS is renamed CONFIG.BAK.
  338. '**
  339. '** Arguments:
  340. '**     szFile$ - filename of driver
  341. '**     szDevText$ - driver pathname and invocation options, e.g.,
  342. '**               "C:\PLUGPLAY\DRIVERS\DOS\DWCFGMG.SYS"
  343. '**
  344. '******************************************************************************
  345. SUB AddDosDriver( szFile$, szDevText$ ) STATIC
  346.  
  347. '' read CONFIG.SYS and write CONFIG.NEW line by line.  delete any line with a
  348. '' matching driver name
  349. ''
  350.     OPEN "C:\CONFIG.NEW" FOR OUTPUT AS #2
  351.     PRINT #2, "DEVICE="; szDevText$
  352.     IF NOT EXISTS( "C:\CONFIG.SYS" ) THEN
  353.         cfg% = 0
  354.         GOTO NOCFGSYS
  355.     END IF
  356.  
  357.     cfg% = 1
  358.     OPEN "C:\CONFIG.SYS" FOR INPUT  AS #1
  359.  
  360.     WHILE NOT( EOF( 1 ) )
  361.         LINE INPUT #1, szLine$
  362.         szTest$ = UCASE$( szLine$ )
  363.         pos% = INSTR( szTest$, szFile$ )
  364.         IF pos% = 0 THEN
  365.             PRINT #2, szLine$
  366.         END IF
  367.     WEND
  368.  
  369. NOCFGSYS:
  370.     CLOSE #2
  371.  
  372.     IF cfg% = 1 THEN
  373.         CLOSE #1
  374.         IF EXISTS( "C:\CONFIG.BAK" ) THEN
  375.             KILL "C:\CONFIG.BAK"
  376.         END IF
  377.         NAME "C:\CONFIG.SYS" AS "C:\CONFIG.BAK"
  378.     END IF
  379.     NAME "C:\CONFIG.NEW" AS "C:\CONFIG.SYS"
  380.  
  381. END SUB
  382.  
  383. '******************************************************************************
  384. '**
  385. '** subroutine:  CommentOutVxD
  386. '**
  387. '** Purpose:   Puts a comment character in front of a VxD invocation in 
  388. '**            the windows\system.ini file.
  389. '**
  390. '** Arguments:
  391. '**     szVxD$ - name of VxD
  392. '**     szWindowsDir$ - The windows directory: e.g. c:\windows\
  393. '**
  394. '******************************************************************************
  395. SUB CommentOutVxD ( szVxD$, szWindowsDir$ ) STATIC
  396.  
  397. '' read system.ini and write system.new line by line.  
  398. ''
  399.     szCurDir$=CURDIR$
  400.     CHDRIVE szWindowsDir$
  401.     szWinDirNoSlash$=MID$ (szWindowsDir,1,LEN(szWindowsDir)-1)
  402.     CHDIR szWinDirNoSlash$
  403.     OPEN szWindowsDir$ + "SYSINI.NEW" FOR OUTPUT AS #2
  404.     OPEN szWindowsDir$ + "SYSTEM.INI" FOR INPUT  AS #1
  405.  
  406.     WHILE NOT( EOF( 1 ) )
  407.         LINE INPUT #1, szLine$
  408.         szTest$ = UCASE$( szLine$ )
  409.         pos% = INSTR( szTest$, szVxD$ )
  410.         IF pos% = 0 THEN
  411.             PRINT #2, szLine$
  412.             ELSE 
  413.                 PRINT #2, ";"; szLine$
  414.         END IF
  415.     WEND
  416.  
  417.  
  418.     CLOSE #2
  419.     CLOSE #1
  420.         IF EXISTS( "SYSINI.BAK" ) THEN
  421.             KILL "SYSINI.BAK"
  422.         END IF
  423.         NAME "SYSTEM.INI" AS "SYSINI.BAK"
  424.     NAME "SYSINI.NEW" AS "SYSTEM.INI"
  425.  
  426.     CHDRIVE szCurDir$
  427.     CHDIR szCurDir$
  428. END SUB
  429.  
  430. '******************************************************************************
  431. '**
  432. '** function:  MakePath
  433. '**
  434. '** Purpose:   Appends a file name to the end of a directory path, inserting a
  435. '**            backslash character as needed.
  436. '** Arguments:
  437. '**     szDir$  - full directory path (with optional ending "\")
  438. '**     szFile$ - filename to append to directory
  439. '** Returns:
  440. '**     Resulting fully qualified path name.
  441. '******************************************************************************
  442. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  443.  
  444.     IF szDir$ = "" THEN
  445.         MakePath = szFile$
  446.     ELSEIF szFile$ = "" THEN
  447.         MakePath = szDir$
  448.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  449.         MakePath = szDir$ + szFile$
  450.     ELSE
  451.         MakePath = szDir$ + "\" + szFile$
  452.     END IF
  453.  
  454. END FUNCTION
  455.  
  456.  
  457. '******************************************************************************
  458. '**
  459. '** subroutine:  AddBuffers
  460. '**
  461. '** Purpose:   Checks to see if the entry in CONFIG.SYS for BUFFERS=<Buffer #) 
  462. '**            ig greater or equal to 20. If not BUFFERS will be set to 20. 
  463. '**            If CONFIG.SYS doesn't exist, a new one is created.
  464. '**            An existing CONFIG.SYS is renamed CONFIG.BAK.
  465. '**
  466. '** Arguments:
  467. '**     szBUF$ - filename of driver
  468. '**                                                               
  469. '**                                                           
  470. '**
  471. '******************************************************************************
  472. SUB AddBuffers STATIC
  473.  
  474. '' read CONFIG.SYS and write CONFIG.NEW line by line.
  475. '' 
  476. ''
  477.     DIDBUF = 0
  478.     OPEN "C:\CONFIG.NEW" FOR OUTPUT AS #2
  479.     IF NOT EXISTS( "C:\CONFIG.SYS" ) THEN
  480.         cfg% = 0
  481.         GOTO WRITENEWCFG
  482.     END IF
  483.  
  484.     cfg% = 1
  485.     OPEN "C:\CONFIG.SYS" FOR INPUT  AS #1
  486.  
  487.     WHILE NOT( EOF( 1 ) )
  488.         LINE INPUT #1, szLine$
  489.         szTest$ = UCASE$( szLine$ )
  490.         pos% = INSTR( szTest$, "BUFFERS=")
  491.         IF pos% = 0 THEN
  492.             PRINT #2, szLine$
  493.         ELSE
  494.             szBUFFS$ = szLine$
  495.              BUF% = VAL(MID$ (szTEST$, 9, 2))
  496. IF BUF >= 20 AND DIDBUF = 0 then
  497.             PRINT #2, szBUFFS$
  498.             DIDBUF = 1
  499.         ELSE
  500.             PRINT #2, "BUFFERS=20"
  501.             DIDBUF = 1
  502.         END IF
  503.  
  504.         END IF
  505.  
  506.         
  507.     WEND
  508.  
  509.         
  510. WRITENEWCFG:
  511.     IF cfg% = 0 THEN
  512.         PRINT #2, "BUFFERS=20"
  513.     End IF
  514.  
  515.     CLOSE #2
  516.     IF cfg% = 1 THEN
  517.         CLOSE #1
  518.         IF EXISTS( "C:\CONFIG.BAK" ) THEN
  519.             KILL "C:\CONFIG.BAK"
  520.         END IF
  521.         NAME "C:\CONFIG.SYS" AS "C:\CONFIG.BAK"
  522.     END IF
  523.     NAME "C:\CONFIG.NEW" AS "C:\CONFIG.SYS"
  524.  
  525. END SUB
  526.